<?php

/**
 *	@name TasksList
 *	@copyright : SMART - ULg (www.smart.ulg.ac.be)		
 *
**/


/**
 * Class TasksList : 
 * description
 * 
 * $Rev$ 
 * $LastChangedRevision$
 * $LastChangedBy$
 * $LastChangedDate$
 * $HeadURL$
 *
 * @name ProjectsListBroker
 * @package webservices/broker
 * @author : JPh HUMBLET
 * @copyright : SMART - ULg (www.smart.ulg.ac.be)
 * @category : ExAMS::Core
 *
**/

class TasksList
{
	
	/* properties */
	private $project;
	private $selectedUser;


	/**
     * Class Constructor
    **/
	function __construct( $p, $u ){ 
		$this->project = $p; 
		$this->selectedUser = $u;
	}
	
	/**
	 * getTasksList
	 * undocumented function
	 *
	 * @return void
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	public function getTasksForUser($user="") {
		if ($user == "") {
			$user = $this->selectedUser;
		}
		$a = $this->project->getAssignments();
		$r = $this->project->getResources();
		$t = $this->project->getTasks();
		
		$myUser = $r->getByName( $user );
		
		$myAssignments = $a->getByUserID( (int) $myUser->UID );
		
		$myTasks = array();
		foreach ($myAssignments as $assign) {
			$myTasks[] = $t->getByID($assign->TaskUID);
		}
		return $myTasks;
		
	}
	

}


?>